﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Excel = Microsoft.Office.Interop.Excel;
using System.Threading;
using System.Net;
using System.Collections;
using System.IO;

using INSAForManagers.Views;

namespace INSAForManagers
{
    public partial class FormACard : Form
    {
        private string fileName;
        private bool canPrint = false;

        public FormACard()
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            FormMain.setMnuSACardEnabled();
            this.Close();
        }


        private void lnkCareerPoint_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            FormCareer f = new FormCareer(this);
            f.ShowDialog();
        }

        private void lnkEduPoint_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (txtJobLevel.Text.Equals(""))
            {
                MessageBox.Show("기본신상정보를 먼저 읽거나 대상자 성명과 개인번호를 입력한 뒤 조회한 후 다시 시도해주세요!  ", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            FormEducation f = new FormEducation(this);
            f.ShowDialog();
        }

        private void lnkResearchPoint_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (txtJobLevel.Text.Equals(""))
            {
                MessageBox.Show("기본신상정보를 먼저 읽거나 대상자 성명과 개인번호를 입력한 뒤 조회한 후 다시 시도해주세요!  ", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            FormResearch f = new FormResearch(this);
            f.ShowDialog();
        }

        private void lnkScholarPoint_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (txtJobLevel.Text.Equals(""))
            {
                MessageBox.Show("기본신상정보를 먼저 읽거나 대상자 성명과 개인번호를 입력한 뒤 조회한 후 다시 시도해주세요!  ", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            FormScholar f = new FormScholar(this);
            f.ShowDialog();
        }

        private void lnkAdditionPoint_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (txtJobLevel.Text.Equals(""))
            {
                MessageBox.Show("기본신상정보를 먼저 읽거나 대상자 성명과 개인번호를 입력한 뒤 조회한 후 다시 시도해주세요!  ", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            FormAddition f = new FormAddition(this, txtPCode.Text);
            f.ShowDialog();
        }

        //현직위 항목을 변경할 때
        private void cboJobLevel_SelectedIndexChanged(object sender, EventArgs e)
        {
            //직위 콤보박스 선택 값
            txtJobLevel.Text = cboJobLevel.Items[cboJobLevel.SelectedIndex].ToString();

            //직위: 교감인 경우
            if (cboJobLevel.SelectedIndex == 1)
            {
                txtLicenseSubject.ReadOnly = false;
                txtLicenseSubject.BackColor = Color.White;
            }
            //직위: 교사인 경우
            else
            {
                txtLicenseSubject.ReadOnly = true;
                txtLicenseSubject.BackColor = Color.LightGray;
            }

            resetData();
        }

        //선택 버튼을 클릭할 때
        private void btnTargetSelect_Click(object sender, EventArgs e)
        {
            txtName.Text = txtTarget.Text;
        }

        private void btnXlsRead_Click(object sender, EventArgs e)
        {
            if (cboJobLevel.SelectedIndex == -1 && txtTarget.Text.Equals(""))
            {
                MessageBox.Show("현직위와 대상자를 입력하고 읽기 버튼을 클릭하세요!    ", "확인");
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "엑셀 파일(*.xls)|*.xls";
            dlg.Multiselect = false;
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                fileName = dlg.FileName;
                Thread t = new Thread(new ThreadStart(readXlsFile));
                t.Start();
            }
        }

        private void readXlsFile()
        {
            Util.openXls(fileName);

            Excel.Range range = Util.OSheet.get_Range("A1", "T200");
            object[,] data = (object[,])range.get_Value(Missing.Value);

            if (!txtTarget.Text.Equals(data[3, 1].ToString()))
            {

                MessageBox.Show(data[3, 1].ToString() + " 대상자의 인사기록 파일이 아닙니다.    ", "오류");
                Util.closeXls();
                return;
            }

            txtNameHanJa.Text = data[3, 9].ToString();

            string[] jumin = data[3, 16].ToString().Split(new char[] { '-' });

            txtPNum1.Text = jumin[0];
            txtPNum2.Text = jumin[1];

            txtOrganName.Text = data[5, 8].ToString();
                        
            //자격 및 취득일
            for (int i = 1; i <= data.GetUpperBound(0); i++)
            {
                if (data[i, 1] == null) continue;

                if (data[i, 1].ToString().Equals("5. 자격면허"))
                {
                    
                    int nRow = i + 2;
                    txtLicenseSubject.Text = data[nRow, 4].ToString();
                    string tmp = data[nRow, 3].ToString();
                    string licLevel = tmp.Substring(tmp.IndexOf('(')+1, 1);
                    cboLicenseLevel.SelectedIndex = Int32.Parse(licLevel) - 1;
                    dtpLicenseDate.Value = DateTime.Parse(data[nRow, 1].ToString().Replace('.','-'));

                    break;
                }
            }


            Util.closeXls();
        }

        private void txtPNum2_TextChanged(object sender, EventArgs e)
        {
            if (txtPNum2.Text.Length == 0) return;

            string i = txtPNum2.Text.Substring(0, 1);
            if (i.Equals("1"))
            {
                rdoMan.Checked = true;
            }
            else
            {
                rdoWoman.Checked = true;
            }
        }

        private void lnkForm_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            dlg.Filter = "엑셀 파일(*.xls) | *.xls";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                WebClient client = new WebClient();
                client.DownloadFile(Application.StartupPath + "\\AList.xls", dlg.FileName);
            }
        }

        private void lnkXlsRead_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (cboJobLevel.SelectedIndex == -1 || txtTarget.Text.Equals(""))
            {
                MessageBox.Show("현직위와 대상자 성명을 모두 입력한 후 다시 시도하세요.    ", "확인");
                return;
            }

            if (txtPCode.Text.Length != 10)
            {
                MessageBox.Show("개인번호를 정확하게 입력하세요!     ", "확인");                
                return;
            }

            OpenFileDialog dlg = new OpenFileDialog();
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            dlg.Filter = "엑셀 파일(*.xls) | *.xls";
            dlg.Multiselect = false;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                fileName = dlg.FileName;
                Thread t = new Thread(new ThreadStart(readXlsList));
                t.Start();
            }
        }

        private void readXlsList()
        {
            try
            {
                //엑셀 열기
                Util.openXls(fileName);

                //Range 객체 선언
                Excel.Range range = null;

                /*********************************
                 * 두 번째 시트 - 기본신상정보
                 *********************************/
                Util.changeSheet(2);

                //소속 및 경력
                range = Util.OSheet.get_Range("A4", "E4");
                object[,] val = (object[,])range.get_Value(Missing.Value);

                if (!txtTarget.Text.Equals(val[1, 3].ToString()))
                {
                    MessageBox.Show("엑셀 파일이 입력 대상자의 파일인지 확인해보세요! ", "확인", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Util.closeXls();
                    return;
                }

                if (val[1, 1] == null || val[1, 2] == null || val[1, 3] == null)
                {
                    MessageBox.Show("소속 및 경력 정보가 누락되었습니다.   ", "확인");
                    Util.closeXls();
                    return;
                }

                if (!val[1, 1].ToString().Equals(DBUtil.getOrganName(Config.Mvi.Organ)))
                {
                    MessageBox.Show("소속이 일치하지 않습니다.    ", "확인");
                    Util.closeXls();
                    return;
                }

                txtOrganName.Text = val[1, 1].ToString();
                txtJobLevel.Text = val[1, 2].ToString();
                txtName.Text = val[1, 3].ToString();
                txtNameHanJa.Text = val[1, 4].ToString();
                string tmp = val[1, 5].ToString();
                if (tmp.IndexOf('-') >= 0)
                {
                    tmp = tmp.Remove(tmp.IndexOf('-'), 1);
                }

                if (tmp.Length != 13)
                {
                    MessageBox.Show("주민등록번호의 숫자 개수를 확인하세요!   ", "확인");
                    Util.closeXls();
                    return;
                }
                txtPNum1.Text = tmp.Substring(0, 6);
                txtPNum2.Text = tmp.Substring(6, 7);

                int tmpInx = Int32.Parse(tmp.Substring(6, 1));
                if (tmpInx % 2 == 0)
                {
                    rdoWoman.Checked = true;
                }
                else
                {
                    rdoMan.Checked = true;
                }

                //최상위 자격 및 취득일
                range = Util.OSheet.get_Range("A10", "G10");
                val = (object[,])range.get_Value(Missing.Value);
                if (val[1, 1] == null || val[1, 2] == null || val[1, 3] == null || val[1, 4] == null || val[1, 5] == null || val[1, 6] == null || val[1, 7] == null)
                {
                    MessageBox.Show("최상위 자격 및 취득일에 누락된 항목이 있습니다.   ", "확인");
                    Util.closeXls();
                    return;
                }

                txtLicenseSubject.Text = val[1, 1].ToString();
                cboLicenseLevel.SelectedItem = val[1, 2].ToString();
                dtpLicenseDate.Value = DateTime.Parse(val[1, 3].ToString());
                cboCYear.SelectedItem = val[1, 4].ToString();
                cboCMonth.SelectedItem = val[1, 5].ToString();
                cboTYear.SelectedItem = val[1, 6].ToString();
                cboTMonth.SelectedItem = val[1, 7].ToString();

                //최종 학력
                range = Util.OSheet.get_Range("B15", "F17");
                val = (object[,])range.get_Value(Missing.Value);
                if (val[1, 1] == null || val[1, 3] == null || val[1, 4] == null)
                {
                    MessageBox.Show("최종 학력에 누락된 항목이 있습니다.   ", "확인");
                    Util.closeXls();
                    return;
                }

                txtUniversityName.Text = val[1, 1].ToString();
                txtCollegeName.Text = val[1, 3].ToString();
                txtSpecialName.Text = val[1, 4].ToString();
                txtFirstSubjectName.Text = val[1, 5].ToString();

                if (val[2, 1] != null)
                {
                    txtGUniversityName.Text = val[2, 1].ToString();
                    txtGCollegeName.Text = val[2, 3].ToString();
                    txtGSpecialName.Text = val[2, 4].ToString();
                }

                if (val[3, 1] != null)
                {
                    txtETCCollegeName.Text = val[3, 1].ToString();
                    txtETCSpecialName.Text = val[3, 4].ToString();
                }

                Util.closeXls();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Util.closeXls();
            }
        }

        private void lnkFindUser_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (txtTarget.Text.Length == 0 || txtTarget.Text.Equals("성명"))
            {
                MessageBox.Show("대상자를 선택하세요!   ","확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTarget.Focus();
                return;
            }

            if (txtPCode.Text.Length == 0 || txtPCode.Text.Equals("개인번호"))
            {
                MessageBox.Show("대상자를 선택하세요!   ", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtPCode.Focus();
                return;
            }

            try
            {
                fineUser();
                
                Thread t = new Thread(new ThreadStart(initData));
                t.Start();

                canPrint = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }

        private void fineUser()
        {
            if (cboJobLevel.SelectedIndex == 0)
            {
                string userName = txtTarget.Text;
                ArrayList list = DBUtil.getMTargetPCode(userName);

                if (list.Count > 1)
                {
                    FormUserList f = new FormUserList(this, list);
                    f.ShowDialog();
                }
                else if (list.Count == 1)
                {
                    ArrayList tmp = (ArrayList)list[0];
                    txtPCode.Text = tmp[0].ToString();
                    txtOrganName.Text = DBUtil.getOrganName(Config.Mvi.Organ);
                    txtName.Text = userName;
                    txtLicenseSubject.Text = DBUtil.getSubjectInfo(txtPCode.Text);
                }
                else
                {
                    MessageBox.Show("등록된 대상자가 없습니다.   ", "확인");
                }
            }
        }

        private void initData()
        {
            try
            {
                string pcode = txtPCode.Text;

                ArrayList list1 = DBUtil.getListFromListType1(pcode);

                if (list1.Count == 0)
                {
                    resetData();
                    return;
                }

                if (list1.Count > 0)
                {
                    //현재 설정된 값을 사용
                    //txtOrganName.Text = list1[1].ToString().Equals("") ? DBUtil.getOrganName(Config.Mvi.Organ) : list1[1].ToString();
                    //txtJobLevel.Text = list1[4].ToString();
                    //txtName.Text = list1[5].ToString();
                    txtJobLevel.Text = list1[4].ToString();
                    txtNameHanJa.Text = list1[6].ToString();
                    if (list1[2].ToString().Length > 0)
                    {
                        txtPNum1.Text = list1[2].ToString().Substring(0, 6);
                        txtPNum2.Text = list1[2].ToString().Substring(6, 7);
                    }
                    if (list1[3].ToString().Equals("남"))
                    {
                        rdoMan.Checked = true;
                    }
                    else
                    {
                        rdoWoman.Checked = true;
                    }
                }

                ArrayList list2 = DBUtil.getListFromListType2(pcode);
                if (list2.Count > 0)
                {
                    txtLicenseSubject.Text = list2[1].ToString();
                    cboLicenseLevel.SelectedItem = list2[2].ToString();
                    dtpLicenseDate.Value = DateTime.Parse(list2[3].ToString());
                    cboCYear.SelectedItem = list2[4].ToString();
                    cboCMonth.SelectedItem = list2[5].ToString();
                    cboTYear.SelectedItem = list2[6].ToString();
                    cboTMonth.SelectedItem = list2[7].ToString();
                }

                ArrayList list3 = DBUtil.getListFromListType3(pcode);
                if (list3.Count > 0)
                {
                    txtFirstSubjectName.Text = list3[1].ToString();
                    txtUniversityName.Text = list3[2].ToString();
                    txtCollegeName.Text = list3[3].ToString();
                    txtSpecialName.Text = list3[4].ToString();
                    txtGUniversityName.Text = list3[5].ToString();
                    txtGCollegeName.Text = list3[6].ToString();
                    txtGSpecialName.Text = list3[7].ToString();
                    txtETCSpecialName.Text = list3[8].ToString();
                    txtETCCollegeName.Text = list3[9].ToString();
                }

                ArrayList list4 = DBUtil.getListFromListType4(pcode);
                if (list4.Count > 0)
                {
                    txtTotalEvaluePoint.Text = Double.Parse(list4[2].ToString()).ToString("#.000");
                    txtCareerpoint.Text = Double.Parse(list4[3].ToString()).ToString("#0.0000");
                    txtEduPoint.Text = Double.Parse(list4[4].ToString()).ToString("#0.0000");
                    txtResearchPoint.Text = Double.Parse(list4[5].ToString()).ToString("#0.0000");
                    txtScholarPoint.Text = Double.Parse(list4[6].ToString()).ToString("#0.0000");
                    txtAdditionPoint.Text = Double.Parse(list4[7].ToString()).ToString("#0.0000");
                    txtTotalPoint.Text = Double.Parse(list4[8].ToString()).ToString("#0.0000");
                    txtETC.Text = list4[9].ToString();

                    calcTrainning();
                    calcTotalPoint();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }

        private void resetData()
        {
            try
            {
                //txtPCode.Text = "개인번호";
                //txtTarget.Text = "성명";
                txtOrganName.Text = DBUtil.getOrganName(Config.Mvi.Organ);
                txtJobLevel.Text = "";
                txtName.Text = !txtTarget.Text.Equals("성명")?txtTarget.Text:"";
                txtNameHanJa.Text = "";
                txtPNum1.Text = "";
                txtPNum2.Text = "";
                rdoMan.Checked = true;

                txtLicenseSubject.Text = cboJobLevel.Text;
                cboLicenseLevel.SelectedIndex = -1;
                dtpLicenseDate.Value = DateTime.Now.Date;
                cboCYear.SelectedIndex = -1;
                cboCMonth.SelectedIndex = -1;
                cboTYear.SelectedIndex = -1;
                cboTMonth.SelectedIndex = -1;                

                txtFirstSubjectName.Text = "";
                txtUniversityName.Text = "";
                txtCollegeName.Text = "";
                txtSpecialName.Text = "";
                txtGUniversityName.Text = "";
                txtGCollegeName.Text = "";
                txtGSpecialName.Text = "";
                txtETCSpecialName.Text = "";
                txtETCCollegeName.Text = "";


                txtTotalEvaluePoint.Text = "0.0";
                txtCareerpoint.Text = "0.0";
                txtEduPoint.Text = "0.0";
                txtResearchPoint.Text = "0.0";
                txtScholarPoint.Text = "0.0";
                txtAdditionPoint.Text = "0.0";
                txtTotalTrainningPoint.Text = "0.0";
                txtTotalPoint.Text = "0.0";
                txtETC.Text = "";
                
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            
            string pcode = txtPCode.Text;
            if (pcode.Length != 10)
            {
                if (cboJobLevel.SelectedIndex == 0)
                {
                    MessageBox.Show("현직위와 성명을 입력하고 조회를 클릭하세요.   ", "확인");                    
                }
                else
                {
                    MessageBox.Show("교감 선생님께서는 개인번호를 직접 입력한 후 조회 버튼을 클릭해주세요.   ", "확인");
                    txtPCode.Focus();
                }
                return;
            }

            if (MessageBox.Show("저장하시겠습니까?  ", "확인", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {

                try
                {
                    //소속 및 경력
                    ArrayList list1 = new ArrayList();
                    list1.Add(pcode);
                    list1.Add(txtOrganName.Text);
                    list1.Add(txtPNum1.Text + txtPNum2.Text);
                    list1.Add(rdoMan.Checked ? "남" : "여");
                    list1.Add(txtJobLevel.Text);
                    list1.Add(txtName.Text);
                    list1.Add(txtNameHanJa.Text);

                    if (DBUtil.isExistedListType1(pcode))
                    {
                        DBUtil.updateListType1(list1);
                    }
                    else
                    {
                        DBUtil.insertListType1(list1);
                    }

                    //최상위 자격 및 취득일
                    ArrayList list2 = new ArrayList();
                    list2.Add(pcode);
                    list2.Add(txtLicenseSubject.Text);
                    list2.Add(cboLicenseLevel.SelectedItem.ToString());
                    list2.Add(dtpLicenseDate.Value);
                    list2.Add(Int32.Parse(cboCYear.SelectedItem.ToString()));
                    list2.Add(Int32.Parse(cboCMonth.SelectedItem.ToString()));
                    list2.Add(Int32.Parse(cboTYear.SelectedItem.ToString()));
                    list2.Add(Int32.Parse(cboTMonth.SelectedItem.ToString()));                    

                    if (DBUtil.isExistedListType2(pcode))
                    {
                        DBUtil.updateListType2(list2);
                    }
                    else
                    {
                        DBUtil.insertListType2(list2);
                    }

                    //최종 학력
                    ArrayList list3 = new ArrayList();
                    list3.Add(pcode);
                    list3.Add(txtFirstSubjectName.Text);
                    list3.Add(txtUniversityName.Text);
                    list3.Add(txtCollegeName.Text);
                    list3.Add(txtSpecialName.Text);
                    list3.Add(txtGUniversityName.Text);
                    list3.Add(txtGCollegeName.Text);
                    list3.Add(txtGSpecialName.Text);
                    list3.Add(txtETCSpecialName.Text);
                    list3.Add(txtETCCollegeName.Text);

                    if (DBUtil.isExistedListType3(pcode))
                    {
                        DBUtil.updateListType3(list3);
                    }
                    else
                    {
                        DBUtil.insertListType3(list3);
                    }

                    //평정
                    ArrayList list4 = new ArrayList();
                    list4.Add(pcode);
                    list4.Add(Double.Parse(txtTotalEvaluePoint.Text));
                    list4.Add(Double.Parse(txtCareerpoint.Text));
                    list4.Add(Double.Parse(txtEduPoint.Text));
                    list4.Add(Double.Parse(txtResearchPoint.Text));
                    list4.Add(Double.Parse(txtScholarPoint.Text));
                    list4.Add(Double.Parse(txtAdditionPoint.Text));
                    list4.Add(Double.Parse(txtTotalPoint.Text));
                    list4.Add(Util.removeSpecialChars(txtETC.Text));

                    if (DBUtil.isExistedListType4(pcode))
                    {
                        DBUtil.updateListType4(list4);
                    }
                    else
                    {
                        DBUtil.insertListType4(list4);
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                MessageBox.Show("저장하였습니다.   ", "확인", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void txtTarget_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void txtTarget_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    fineUser();

                    Thread t = new Thread(new ThreadStart(initData));
                    t.Start();

                    canPrint = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void lnkCalcEvalue_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            FormEvalueList f = new FormEvalueList(this, cboJobLevel.SelectedIndex);
            f.ShowDialog();
        }

        private void lnkCalcTrainning_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                calcTrainning();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "확인", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void calcTrainning()
        {
            double eduPoint = Double.Parse(txtEduPoint.Text);
            double resPoint = Double.Parse(txtResearchPoint.Text);
            double schPoint = Double.Parse(txtScholarPoint.Text);

            if (resPoint + schPoint > 3.0)
            {
                MessageBox.Show("연구대회입상 실적과 학위취득실적의 합이 3.0을 초과할 수 없습니다.\n관련 항목의 점수를 조정하십시오.","확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            double totalPoint = eduPoint + resPoint + schPoint;
            txtTotalTrainningPoint.Text = totalPoint.ToString("#0.000");
        }

        private void lnkCalcTotalPoint_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                calcTotalPoint();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "확인", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            
        }

        private void calcTotalPoint()
        {
            double evaluePoint = Double.Parse(txtTotalEvaluePoint.Text);
            double careerPoint = Double.Parse(txtCareerpoint.Text);
            double trainningPoint = Double.Parse(txtTotalTrainningPoint.Text);
            double addtionPoint = Double.Parse(txtAdditionPoint.Text);

            double totalPoint = evaluePoint + careerPoint + trainningPoint + addtionPoint;

            txtTotalPoint.Text = totalPoint.ToString("#0.0000");
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (canPrint == false)
            {
                MessageBox.Show("먼저 현직위, 성명, 개인번호를 입력한 후 조회를 클릭하세요!    ", "확인");
                return;
            }

            int lenPcode = txtPCode.Text.Length;

            if (lenPcode == 0)
            {
                MessageBox.Show("개인번호가 누락되어 있습니다.     ","확인");
                txtPCode.Focus();
                return;
            }
            
            if (lenPcode != 10)
            {
                MessageBox.Show("개인번호가 " + lenPcode.ToString() + "자리 입니다.   \n\n개인번호는 10자리 이어야합니다.   ", "확인");
                return;
            }

            if (MessageBox.Show("평정카드 및 평정표를 인쇄하시겠습니까?    ", "확인", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {

                    Util.openXls(Application.StartupPath + @"\ProCard");

                    Excel.Range range;

                    //평정카드 시트
                    
                    if (rdoTargetType1.Checked == true)
                    {
                        string targetLevel = cboJobLevel.SelectedItem.ToString().Equals("교사") ? "교감" : "교장";
                        range = Util.OSheet.get_Range("A2", Missing.Value);
                        range.set_Value(Missing.Value, targetLevel + " 연수대상자 평정카드");
                    }
                    else
                    {
                        string targetLevel = cboJobLevel.SelectedItem.ToString().Equals("교사") ? "교감" : "교장";
                        range = Util.OSheet.get_Range("A2", Missing.Value);
                        range.set_Value(Missing.Value, targetLevel + " 승진후보자 평정카드");
                    }

                    range = Util.OSheet.get_Range("D2", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("B4", Missing.Value);
                    range.set_Value(Missing.Value, txtOrganName.Text);

                    range = Util.OSheet.get_Range("F4", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("H4", Missing.Value);
                    range.set_Value(Missing.Value, txtName.Text + "\n(" + txtNameHanJa.Text + ")");

                    range = Util.OSheet.get_Range("J4", Missing.Value);
                    range.set_Value(Missing.Value, txtPNum1.Text + "-\n" + txtPNum2.Text);

                    range = Util.OSheet.get_Range("L4", Missing.Value);
                    range.set_Value(Missing.Value, rdoMan.Checked ? "남" : "여");

                    range = Util.OSheet.get_Range("B5", Missing.Value);
                    range.set_Value(Missing.Value, "자격(" + txtLicenseSubject.Text + "," + cboLicenseLevel.SelectedItem.ToString() + ")\n(" + dtpLicenseDate.Value.ToShortDateString() + ")");

                    range = Util.OSheet.get_Range("G5", Missing.Value);
                    int cmonth = Int32.Parse(cboCMonth.SelectedItem.ToString());
                    range.set_Value(Missing.Value, cboCYear.SelectedItem.ToString() + "." + (cmonth < 10 ? "0" + cmonth.ToString() : cmonth.ToString()) + " ");

                    range = Util.OSheet.get_Range("I5", Missing.Value);
                    int tmonth = Int32.Parse(cboTMonth.SelectedItem.ToString());
                    range.set_Value(Missing.Value, cboTYear.SelectedItem.ToString() + "." + (tmonth < 10 ? "0" + tmonth.ToString() : tmonth.ToString()) + " ");

                    //평정제외경력
                    range = Util.OSheet.get_Range("K5", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getExCareerInfo(txtPCode.Text));

                    range = Util.OSheet.get_Range("B6", Missing.Value);
                    string tmp = "";
                    if (txtUniversityName.Text.Length > 0)
                    {
                        tmp += txtUniversityName.Text + " " + txtCollegeName.Text + " " + txtSpecialName.Text + " 졸업";
                    }
                    if (txtGUniversityName.Text.Length > 0)
                    {
                        tmp += "\n" + txtGUniversityName.Text + " " + txtGCollegeName.Text + " " + txtGSpecialName.Text + " 졸업";
                    }
                    if (txtETCCollegeName.Text.Length > 0)
                    {
                        tmp += "\n" + "시험검정" + txtETCSpecialName.Text + ", " + txtETCCollegeName.Text + " 졸업";
                    }
                    range.set_Value(Missing.Value, tmp);

                    range = Util.OSheet.get_Range("L6", Missing.Value);
                    range.set_Value(Missing.Value, txtFirstSubjectName.Text);

                    ArrayList peList = DBUtil.getPersonalEvalue2009(txtPCode.Text);

                    if (peList.Count != 0)
                    {
                        range = Util.OSheet.get_Range("B9", Missing.Value);
                        range.set_Value(Missing.Value, peList[2]);

                        range = Util.OSheet.get_Range("C9", Missing.Value);
                        range.set_Value(Missing.Value, peList[1]);

                        range = Util.OSheet.get_Range("D9", Missing.Value);
                        range.set_Value(Missing.Value, peList[0]);
                    }

                    range = Util.OSheet.get_Range("B10", Missing.Value);
                    range.set_Value(Missing.Value, txtTotalEvaluePoint.Text);

                    range = Util.OSheet.get_Range("E9", Missing.Value);
                    range.set_Value(Missing.Value, txtCareerpoint.Text);

                    range = Util.OSheet.get_Range("G9", Missing.Value);
                    range.set_Value(Missing.Value, txtEduPoint.Text);

                    range = Util.OSheet.get_Range("H9", Missing.Value);
                    range.set_Value(Missing.Value, txtResearchPoint.Text);

                    range = Util.OSheet.get_Range("I9", Missing.Value);
                    range.set_Value(Missing.Value, txtScholarPoint.Text);

                    range = Util.OSheet.get_Range("G10", Missing.Value);
                    range.set_Value(Missing.Value, txtTotalTrainningPoint.Text);

                    range = Util.OSheet.get_Range("J9", Missing.Value);
                    range.set_Value(Missing.Value, txtAdditionPoint.Text);

                    range = Util.OSheet.get_Range("K9", Missing.Value);
                    range.set_Value(Missing.Value, txtTotalPoint.Text);

                    range = Util.OSheet.get_Range("B11", Missing.Value);
                    range.set_Value(Missing.Value, txtETC.Text);

                    range = Util.OSheet.get_Range("C13", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Evaluer1 + "\n" + Config.Mvi.Evaluer2);

                    range = Util.OSheet.get_Range("I13", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Confirmer);

                    range = Util.OSheet.get_Range("C12", Missing.Value);
                    range.set_Value(Missing.Value, "교감");

                    range = Util.OSheet.get_Range("I12", Missing.Value);
                    range.set_Value(Missing.Value, "교장");

                    /**************
                     * 경력평정표
                     * *************/
                    Util.changeSheet(2);

                    ArrayList careerList = DBUtil.getListFromCareerTable(txtPCode.Text);

                    range = Util.OSheet.get_Range("B3", Missing.Value);
                    range.set_Value(Missing.Value, txtOrganName.Text);

                    range = Util.OSheet.get_Range("E3", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("G3", Missing.Value);
                    range.set_Value(Missing.Value, txtName.Text);

                    //경력평정정보
                    object[,] careerInfo = new object[6, 7];

                    //시작
                    string[] startDate = new string[6];

                    //끝
                    string[] endDate = new string[6];

                    //근무월수
                    int[] workMonth = new int[6];

                    //근무일수
                    int[] workDay = new int[6];

                    //월평정점(기준)
                    double[] pointPerMonth = new double[6];

                    //일평정점(기준)
                    double[] pointPerDay = new double[6];

                    //월평정점
                    double[] monthlyPoint = new double[6];

                    //일평정점
                    double[] dailyPoint = new double[6];

                    //평정점
                    double[] careerPoint = new double[6];

                    for (int i = 0; i < careerList.Count; i++)
                    {
                        ArrayList data = (ArrayList)careerList[i];

                        if (data[2].ToString().Equals("기본경력"))
                        {
                            if (data[3].ToString().Equals("가경력"))
                            {
                                //근무기관명을 축약형으로 변경하여 저장
                                careerInfo[0, 0] += Util.getShortSchoolName(data[4].ToString()) + " "; 

                                //처음에 시작 날짜가 없을 경우
                                if (startDate[0] == null) startDate[0] = data[5].ToString();

                                //두 번째 부터는 날짜를 비교하여 현재 시작 날짜보다 더 이전이면 교체
                                if (startDate[0].CompareTo(data[5].ToString()) > 0) startDate[0] = data[5].ToString();

                                //처음에 끝 날짜가 없을 경우
                                if (endDate[0] == null) endDate[0] = data[6].ToString();

                                //두 번째 부터는 날짜를 비교하여 현재 날짜 이후이면 교체
                                if (endDate[0].CompareTo(data[6].ToString()) < 0) endDate[0] = data[6].ToString();

                                //기간을 시작 '~' 끝 형식으로 저장
                                careerInfo[0, 1] = startDate[0].Substring(0, 10) + "~\n" + endDate[0].Substring(0, 10);

                                //평정월수
                                workMonth[0] += (int)data[9];

                                //평정일수
                                workDay[0] += (int)data[10];

                                careerInfo[0, 2] = workMonth[0];

                                careerInfo[0, 3] = workDay[0];

                                pointPerMonth[0] = Util.getCareerMonthPoint("기본경력", "가경력");
                                pointPerDay[0] = Util.getCareerDayPoint("기본경력", "가경력");

                                monthlyPoint[0] = (double)data[11];

                                dailyPoint[0] = (double)data[12];

                                careerPoint[0] += (double)data[13];

                                if (workMonth[0] / 12 >= Util.getBasicCareerMaxYear()) careerPoint[0] = Util.getCareerMaxPoint("기본경력", "가경력");

                                //월평정점
                                careerInfo[0, 4] = monthlyPoint[0];

                                //일평정점
                                careerInfo[0, 5] = dailyPoint[0];

                                //평정점
                                careerInfo[0, 6] = careerPoint[0];

                            }
                            else if (data[3].ToString().Equals("나경력"))
                            {
                                careerInfo[1, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[1] == null) startDate[1] = data[5].ToString();
                                if (startDate[1].CompareTo(data[5].ToString()) > 0) startDate[1] = data[5].ToString();

                                if (endDate[1] == null) endDate[1] = data[6].ToString();
                                if (endDate[1].CompareTo(data[6].ToString()) < 0) endDate[1] = data[6].ToString();

                                careerInfo[1, 1] = startDate[1].Substring(0, 10) + "~\n" + endDate[1].Substring(0, 10);

                                //평정월수
                                workMonth[1] += (int)data[9];

                                //평정일수
                                workDay[1] += (int)data[10];

                                careerInfo[1, 2] = workMonth[1];

                                careerInfo[1, 3] = workDay[1];

                                pointPerMonth[1] = Util.getCareerMonthPoint("기본경력", "나경력");
                                pointPerDay[1] = Util.getCareerDayPoint("기본경력", "나경력");

                                monthlyPoint[1] = (double)data[11];

                                dailyPoint[1] = (double)data[12];

                                careerPoint[1] += (double)data[13];

                                if (workMonth[1] / 12 >= Util.getBasicCareerMaxYear()) careerPoint[1] = Util.getCareerMaxPoint("기본경력", "나경력");

                                //월평정점
                                careerInfo[1, 4] = monthlyPoint[1];

                                //일평정점
                                careerInfo[1, 5] = dailyPoint[1];

                                //평정점
                                careerInfo[1, 6] = careerPoint[1];

                            }
                            else if (data[3].ToString().Equals("다경력"))
                            {
                                careerInfo[2, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[2] == null) startDate[2] = data[5].ToString();
                                if (startDate[2].CompareTo(data[5].ToString()) > 0) startDate[2] = data[5].ToString();

                                if (endDate[2] == null) endDate[2] = data[6].ToString();
                                if (endDate[2].CompareTo(data[6].ToString()) < 0) endDate[2] = data[6].ToString();

                                careerInfo[2, 1] = startDate[2].Substring(0, 10) + "~\n" + endDate[2].Substring(0, 10);

                                //평정월수
                                workMonth[2] += (int)data[9];

                                //평정일수
                                workDay[2] += (int)data[10];

                                careerInfo[2, 2] = workMonth[2];

                                careerInfo[2, 3] = workDay[2];

                                monthlyPoint[2] = (double)data[11];

                                dailyPoint[2] = (double)data[12];

                                pointPerMonth[2] = Util.getCareerMonthPoint("기본경력", "다경력");
                                pointPerDay[2] = Util.getCareerDayPoint("기본경력", "다경력");

                                careerPoint[2] += (double)data[13];

                                if (workMonth[2] / 12 >= Util.getBasicCareerMaxYear()) careerPoint[2] = Util.getCareerMaxPoint("기본경력", "다경력");

                                //월평정점
                                careerInfo[2, 4] = monthlyPoint[2];

                                //일평정점
                                careerInfo[2, 5] = dailyPoint[2];

                                //평정점
                                careerInfo[2, 6] = careerPoint[2];
                            }
                        }
                        else if (data[2].ToString().Equals("초과경력"))
                        {
                            if (data[3].ToString().Equals("가경력"))
                            {
                                careerInfo[3, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[3] == null) startDate[3] = data[5].ToString();
                                if (startDate[3].CompareTo(data[5].ToString()) > 0) startDate[3] = data[5].ToString();

                                if (endDate[3] == null) endDate[3] = data[6].ToString();
                                if (endDate[3].CompareTo(data[6].ToString()) < 0) endDate[3] = data[6].ToString();

                                careerInfo[3, 1] = startDate[3].Substring(0, 10) + "~\n" + endDate[3].Substring(0, 10);

                                //평정월수
                                workMonth[3] += (int)data[9];

                                //평정일수
                                workDay[3] += (int)data[10];

                                careerInfo[3, 2] = workMonth[3];

                                careerInfo[3, 3] = workDay[3];

                                pointPerMonth[3] = Util.getCareerMonthPoint("초과경력", "가경력");
                                pointPerDay[3] = Util.getCareerDayPoint("초과경력", "가경력");

                                monthlyPoint[3] = (double)data[11];

                                dailyPoint[3] = (double)data[12];

                                careerPoint[3] += (double)data[13];

                                if (workMonth[3] / 12 >= Util.getAdditiveCareerMaxYear()) careerPoint[3] = Util.getCareerMaxPoint("초과경력", "가경력");

                                //월평정점
                                careerInfo[3, 4] = monthlyPoint[3];

                                //일평정점
                                careerInfo[3, 5] = dailyPoint[3];

                                //평정점
                                careerInfo[3, 6] = careerPoint[3];

                            }
                            else if (data[3].ToString().Equals("나경력"))
                            {
                                careerInfo[4, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[4] == null) startDate[4] = data[5].ToString();
                                if (startDate[4].CompareTo(data[5].ToString()) > 0) startDate[4] = data[5].ToString();

                                if (endDate[4] == null) endDate[4] = data[6].ToString();
                                if (endDate[4].CompareTo(data[6].ToString()) < 0) endDate[4] = data[6].ToString();

                                careerInfo[4, 1] = startDate[4].Substring(0, 10) + "~\n" + endDate[4].Substring(0, 10);

                                //평정월수
                                workMonth[4] += (int)data[9];

                                //평정일수
                                workDay[4] += (int)data[10];

                                careerInfo[4, 2] = workMonth[4];

                                careerInfo[4, 3] = workDay[4];

                                pointPerMonth[4] = Util.getCareerMonthPoint("초과경력", "나경력");
                                pointPerDay[4] = Util.getCareerDayPoint("초과경력", "나경력");

                                monthlyPoint[4] = (double)data[11];

                                dailyPoint[4] = (double)data[12];

                                careerPoint[4] += (double)data[13];

                                if (workMonth[4] / 12 >= Util.getAdditiveCareerMaxYear()) careerPoint[4] = Util.getCareerMaxPoint("초과경력", "나경력");

                                //월평정점
                                careerInfo[4, 4] = monthlyPoint[4];

                                //일평정점
                                careerInfo[4, 5] = dailyPoint[4];

                                //평정점
                                careerInfo[4, 6] = careerPoint[4];

                            }
                            else if (data[3].ToString().Equals("다경력"))
                            {
                                careerInfo[5, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[5] == null) startDate[5] = data[5].ToString();
                                if (startDate[5].CompareTo(data[5].ToString()) > 0) startDate[5] = data[5].ToString();

                                if (endDate[5] == null) endDate[5] = data[6].ToString();
                                if (endDate[5].CompareTo(data[6].ToString()) < 0) endDate[5] = data[6].ToString();

                                careerInfo[5, 1] = startDate[5].Substring(0,10) + "~\n" + endDate[5].Substring(0,10);

                                //평정월수
                                workMonth[5] += (int)data[9];

                                //평정일수
                                workDay[5] += (int)data[10];

                                careerInfo[5, 2] = workMonth[5];

                                careerInfo[5, 3] = workDay[5];

                                pointPerMonth[5] = Util.getCareerMonthPoint("초과경력", "다경력");
                                pointPerDay[5] = Util.getCareerDayPoint("초과경력", "다경력");

                                monthlyPoint[5] = (double)data[11];

                                dailyPoint[5] = (double)data[12];

                                careerPoint[5] += (double)data[13];

                                if (workMonth[5] / 12 >= Util.getAdditiveCareerMaxYear()) careerPoint[5] = Util.getCareerMaxPoint("초과경력", "다경력");

                                //월평정점
                                careerInfo[5, 4] = monthlyPoint[5];

                                //일평정점
                                careerInfo[5, 5] = dailyPoint[5];

                                //평정점
                                careerInfo[5, 6] = careerPoint[5];
                            }

                        }

                    }

                    //엑셀에 경력 평정 정보를 입력하는 부분
                    string[] arrCol = new string[] { "C", "D", "E", "F", "G" };
                    string[] arrRow = new string[] { "6", "7", "8", "10", "11", "12" };

                    for (int i = 0; i <= careerInfo.GetUpperBound(0); i++)
                    {
                        if (careerInfo[i, 0] == null) continue;

                        //근무처직명
                        range = Util.OSheet.get_Range(arrCol[0] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, careerInfo[i, 0]);

                        //재직기간
                        range = Util.OSheet.get_Range(arrCol[1] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, careerInfo[i, 1]);

                        //재직월일수
                        range = Util.OSheet.get_Range(arrCol[2] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, "월: " + careerInfo[i, 2] + "\n일: " + careerInfo[i, 3]);

                        //월평정점, 일평정점(규정상의 정해진 점수)
                        range = Util.OSheet.get_Range(arrCol[3] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, "월: " + pointPerMonth[i].ToString("#0.0000") + "\n일: " + pointPerDay[i].ToString("#0.00000"));

                        //평정점 합계                        
                        range = Util.OSheet.get_Range(arrCol[4] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, careerInfo[i, 6]);

                                              
                    }                    

                    //기본경력 평정점 합계
                    range = Util.OSheet.get_Range("G9", Missing.Value);
                    range.set_Value(Missing.Value, (careerPoint[0] + careerPoint[1] + careerPoint[2]).ToString("#0.00000"));

                    //초과경력 평정점 합계
                    range = Util.OSheet.get_Range("G13", Missing.Value);
                    range.set_Value(Missing.Value, (careerPoint[3] + careerPoint[4] + careerPoint[5]).ToString("#0.00000"));

                    //기본경력, 초과경력 평정점 합계
                    range = Util.OSheet.get_Range("G14", Missing.Value);
                    range.set_Value(Missing.Value, (careerPoint[0] + careerPoint[1] + careerPoint[2] + careerPoint[3] + careerPoint[4] + careerPoint[5]).ToString("#0.00000"));

                    //기본경력 월,일수 합계
                    range = Util.OSheet.get_Range("E9", Missing.Value);
                    int tmpMonth = workMonth[0] + workMonth[1] + workMonth[2];
                    int tmpDay = workDay[0] + workDay[1] + workDay[2];
                    if (tmpDay >= 30)
                    {
                        tmpMonth++;
                        tmpDay -= 30;
                    }
                    range.set_Value(Missing.Value, "월: " + tmpMonth + "\n일: " + tmpDay);

                    //초과경력 월,일수 합계
                    range = Util.OSheet.get_Range("E13", Missing.Value);
                    tmpMonth = workMonth[3] + workMonth[4] + workMonth[5];
                    tmpDay = workDay[3] + workDay[4] + workDay[5];
                    if (tmpDay >= 30)
                    {
                        tmpMonth++;
                        tmpDay -= 30;
                    }
                    range.set_Value(Missing.Value, "월: " + tmpMonth + "\n일: " + tmpDay);

                    //전체 월,일수 합계
                    range = Util.OSheet.get_Range("E14", Missing.Value);
                    tmpMonth = workMonth[0] + workMonth[1] + workMonth[2] + workMonth[3] + workMonth[4] + workMonth[5];
                    tmpDay = workDay[0] + workDay[1] + workDay[2] + workDay[3] + workDay[4] + workDay[5];
                    if (tmpDay >= 30)
                    {
                        tmpMonth++;
                        tmpDay -= 30;
                    }
                    range.set_Value(Missing.Value, "월: " + tmpMonth + "\n일: " + tmpDay);

                    range = Util.OSheet.get_Range("B17", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    range = Util.OSheet.get_Range("B18", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    range = Util.OSheet.get_Range("F17", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Evaluer1 + "\n" + Config.Mvi.Evaluer2);

                    range = Util.OSheet.get_Range("F18", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Confirmer);

                    range = Util.OSheet.get_Range("E17", Missing.Value);
                    range.set_Value(Missing.Value, "교감");

                    range = Util.OSheet.get_Range("E18", Missing.Value);
                    range.set_Value(Missing.Value, "교장");

                    /**************
                     * 연수성적평정표
                     * ************/

                    Util.changeSheet(3);

                    range = Util.OSheet.get_Range("B3", Missing.Value);
                    range.set_Value(Missing.Value, txtOrganName.Text);

                    range = Util.OSheet.get_Range("G3", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("K3", Missing.Value);
                    range.set_Value(Missing.Value, txtName.Text);

                    //교육성적
                    ArrayList eduList = DBUtil.getListFromEduTable(txtPCode.Text);

                    string[] eduCol = new string[] {"A","B", "C", "D", "E", "G", "I", "K"};
                    string[] eduRow = new string[] { "7", "8", "9", "10" };

                    for (int i = 0; i < eduList.Count; i++)
                    {
                        ArrayList data = (ArrayList)eduList[i];

                        range = Util.OSheet.get_Range(eduCol[0] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[2].ToString());

                        range = Util.OSheet.get_Range(eduCol[1] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[3].ToString());

                        range = Util.OSheet.get_Range(eduCol[2] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[4].ToString());

                        range = Util.OSheet.get_Range(eduCol[3] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[5].ToString());

                        range = Util.OSheet.get_Range(eduCol[4] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[6].ToString().Substring(0,10) + "~" + data[7].ToString().Substring(0,10));
                        
                        range = Util.OSheet.get_Range(eduCol[5] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[8].ToString());

                        range = Util.OSheet.get_Range(eduCol[6] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[9].ToString());

                        range = Util.OSheet.get_Range(eduCol[7] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[10].ToString());
                    }

                    //연구대회
                    ArrayList reslist = DBUtil.getListFromResearchTable(txtPCode.Text);

                    string[] resCol = new string[] { "A", "C", "E", "L" };
                    string[] scale1 = new string[] { "F", "G", "H" };
                    string[] scale2 = new string[] { "I", "J", "K" };
                    string[] resRow = new string[] { "15", "16", "17", "18", "19", "20", "21", "22", "23"};

                    for (int i = 0; i < reslist.Count; i++)
                    {
                        ArrayList data = (ArrayList)reslist[i];
                        range = Util.OSheet.get_Range(resCol[0] + resRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[2].ToString());

                        range = Util.OSheet.get_Range(resCol[1] + resRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[3].ToString());

                        range = Util.OSheet.get_Range(resCol[2] + resRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[4].ToString().Substring(0, 10));

                        string strRange = "";
                        if (data[5].ToString().Equals("전국"))
                        {                            
                            switch (data[6].ToString())
                            {
                                case "1등급":
                                    strRange = scale1[0].ToString() + resRow[i].ToString();
                                    break;
                                case "2등급":
                                    strRange = scale1[1].ToString() + resRow[i].ToString();
                                    break;
                                case "3등급":
                                    strRange = scale1[2].ToString() + resRow[i].ToString();
                                    break;
                            }
                        }else if(data[5].ToString().Equals("시도")){
                            switch (data[6].ToString())
                            {
                                case "1등급":
                                    strRange = scale2[0].ToString() + resRow[i].ToString();
                                    break;
                                case "2등급":
                                    strRange = scale2[1].ToString() + resRow[i].ToString();
                                    break;
                                case "3등급":
                                    strRange = scale2[2].ToString() + resRow[i].ToString();
                                    break;
                            }
                        }
                        range = Util.OSheet.get_Range(strRange, Missing.Value);
                        range.set_Value(Missing.Value, "○");

                        range = Util.OSheet.get_Range(resCol[3] + resRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[8].ToString());
                    }

                    //학위취득실적
                    ArrayList scholarlist = DBUtil.getListFromScholarTable(txtPCode.Text);
                    
                    for (int i = 0; i < scholarlist.Count; i++)
                    {
                        ArrayList data = (ArrayList)scholarlist[i];
                        if (data[2].ToString().Equals("석사"))
                        {
                            if (data[3].ToString().Equals("직무관련"))
                            {
                                range = Util.OSheet.get_Range("C27", Missing.Value);
                                range.set_Value(Missing.Value, data[4].ToString());

                                range = Util.OSheet.get_Range("E27", Missing.Value);
                                range.set_Value(Missing.Value, data[5].ToString());

                                range = Util.OSheet.get_Range("H27", Missing.Value);
                                range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10));

                                range = Util.OSheet.get_Range("K27", Missing.Value);
                                range.set_Value(Missing.Value, data[7].ToString());
                            }
                            else
                            {
                                range = Util.OSheet.get_Range("C28", Missing.Value);
                                range.set_Value(Missing.Value, data[4].ToString());

                                range = Util.OSheet.get_Range("E28", Missing.Value);
                                range.set_Value(Missing.Value, data[5].ToString());

                                range = Util.OSheet.get_Range("H28", Missing.Value);
                                range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10));

                                range = Util.OSheet.get_Range("K28", Missing.Value);
                                range.set_Value(Missing.Value, data[7].ToString());
                            }
                        }
                        else
                        {
                            if (data[3].ToString().Equals("직무관련"))
                            {
                                range = Util.OSheet.get_Range("C29", Missing.Value);
                                range.set_Value(Missing.Value, data[4].ToString());

                                range = Util.OSheet.get_Range("E29", Missing.Value);
                                range.set_Value(Missing.Value, data[5].ToString());

                                range = Util.OSheet.get_Range("H29", Missing.Value);
                                range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10));

                                range = Util.OSheet.get_Range("K29", Missing.Value);
                                range.set_Value(Missing.Value, data[7].ToString());
                            }
                            else
                            {
                                range = Util.OSheet.get_Range("C30", Missing.Value);
                                range.set_Value(Missing.Value, data[4].ToString());

                                range = Util.OSheet.get_Range("E30", Missing.Value);
                                range.set_Value(Missing.Value, data[5].ToString());

                                range = Util.OSheet.get_Range("H30", Missing.Value);
                                range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10));

                                range = Util.OSheet.get_Range("K30", Missing.Value);
                                range.set_Value(Missing.Value, data[7].ToString());
                            }
                        }
                    }

                    range = Util.OSheet.get_Range("C34", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    range = Util.OSheet.get_Range("C35", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    range = Util.OSheet.get_Range("I34", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Evaluer1 + "\n" + Config.Mvi.Evaluer2);

                    range = Util.OSheet.get_Range("I35", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Confirmer);

                    range = Util.OSheet.get_Range("G34", Missing.Value);
                    range.set_Value(Missing.Value, "교감");

                    range = Util.OSheet.get_Range("G35", Missing.Value);
                    range.set_Value(Missing.Value, "교장");

                    /**************
                     * 가산점평정표
                     * ************/

                    Util.changeSheet(4);

                    range = Util.OSheet.get_Range("B3", Missing.Value);
                    range.set_Value(Missing.Value, txtOrganName.Text);

                    range = Util.OSheet.get_Range("E3", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("G3", Missing.Value);
                    range.set_Value(Missing.Value, txtName.Text);

                    ArrayList addList = DBUtil.getListFromAdditionTable(txtPCode.Text);

                    string[] addCol = new string[] { "A", "B", "C", "D", "E", "F", "G" };
                    string[] addRow = new string[] { "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44","45" };

                    for (int i = 0; i < addList.Count; i++)
                    {
                        Hashtable data = (Hashtable)addList[i];

                        //구분
                        //Console.WriteLine(addCol[0] + addRow[i]);
                        range = Util.OSheet.get_Range(addCol[0] + addRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data["ADD_ITEM_CONTENT"].ToString());

                        //근무기관
                        range = Util.OSheet.get_Range(addCol[1] + addRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data["ADD_ORGAN"].ToString());

                        //근무기간
                        if (data["ADD_GROUP"].ToString().Equals("B08"))
                        {
                            range = Util.OSheet.get_Range(addCol[2] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["TARGET_START"]);

                        }
                        else if (data["ADD_GROUP"].ToString().Equals("A03"))
                        {
                            range = Util.OSheet.get_Range(addCol[2] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["TARGET_START"].ToString().Substring(0, 10) + "~" + data["TARGET_END"].ToString().Substring(0, 10));

                            range = Util.OSheet.get_Range(addCol[4] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["ADD_MONTH"] + "시간");

                            range = Util.OSheet.get_Range(addCol[3] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, ((int)data["ADD_MONTH"]/15) + "학점");
                        }
                        else
                        {
                            range = Util.OSheet.get_Range(addCol[2] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["ADD_START"].ToString().Substring(0, 10) + "~" + data["ADD_END"].ToString().Substring(0, 10));

                            range = Util.OSheet.get_Range(addCol[3] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["TARGET_START"].ToString().Substring(0, 10) + "~" + data["TARGET_END"].ToString().Substring(0, 10));

                            range = Util.OSheet.get_Range(addCol[4] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, "월: " + data["ADD_MONTH"].ToString() + "\n일: " + data["ADD_DAY"].ToString());
                        }
                        
                        //평정월/일수
                        range = Util.OSheet.get_Range(addCol[5] + addRow[i], Missing.Value);
                        range.set_Value(Missing.Value, "월: " + data["MONTHLY_POINT"].ToString() + "\n일: " + data["DAILY_POINT"].ToString());

                        //월/일 평정점
                        range = Util.OSheet.get_Range(addCol[6] + addRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data["TOTAL_POINT"].ToString());
                    }

                    //평정자 소속
                    range = Util.OSheet.get_Range("B49", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    //확인자 소속
                    range = Util.OSheet.get_Range("B50", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    //평정자 성명
                    range = Util.OSheet.get_Range("D49", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Evaluer1 + "\n" + Config.Mvi.Evaluer2);

                    //확인자 성명
                    range = Util.OSheet.get_Range("D50", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Confirmer);

                    range = Util.OSheet.get_Range("C49", Missing.Value);
                    range.set_Value(Missing.Value, "교감");

                    range = Util.OSheet.get_Range("C50", Missing.Value);
                    range.set_Value(Missing.Value, "교장");

                    Util.OExcel.Visible = true;

                    Util.OExcel.Worksheets.PrintPreview(Missing.Value);

                    Util.closeXls();

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Util.closeXls();
                }

             }
       
        }

        private void lnkHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            HFormACard f = new HFormACard();
            f.Show();
        }

        private void lnkExport_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            int lenPcode = txtPCode.Text.Length;

            if (lenPcode == 0)
            {
                MessageBox.Show("개인번호가 누락되어 있습니다.     ", "확인");
                txtPCode.Focus();
                return;
            }

            if (lenPcode != 10)
            {
                MessageBox.Show("개인번호가 " + lenPcode.ToString() + "자리 입니다.   \n\n개인번호는 10자리 이어야합니다.   ", "확인");
                return;
            }

            if (canPrint == false)
            {
                MessageBox.Show("먼저 현직위, 성명, 개인번호를 입력한 후 조회를 클릭하세요!    ", "확인");
                return;
            }

            if (MessageBox.Show("제출 파일을 생성하시겠습니까?    ", "확인", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {

                    Util.openXls(Application.StartupPath + @"\ProCard");

                    Excel.Range range;

                    //평정카드 시트

                    if (rdoTargetType1.Checked == true)
                    {
                        string targetLevel = cboJobLevel.SelectedItem.ToString().Equals("교사") ? "교감" : "교장";
                        range = Util.OSheet.get_Range("A2", Missing.Value);
                        range.set_Value(Missing.Value, targetLevel + " 연수대상자 평정카드");
                    }
                    else
                    {
                        string targetLevel = cboJobLevel.SelectedItem.ToString().Equals("교사") ? "교감" : "교장";
                        range = Util.OSheet.get_Range("A2", Missing.Value);
                        range.set_Value(Missing.Value, targetLevel + " 승진후보자 평정카드");
                    }

                    range = Util.OSheet.get_Range("D2", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("B4", Missing.Value);
                    range.set_Value(Missing.Value, txtOrganName.Text);

                    range = Util.OSheet.get_Range("F4", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("H4", Missing.Value);
                    range.set_Value(Missing.Value, txtName.Text + "\n(" + txtNameHanJa.Text + ")");

                    range = Util.OSheet.get_Range("J4", Missing.Value);
                    range.set_Value(Missing.Value, txtPNum1.Text + "-\n" + txtPNum2.Text);

                    range = Util.OSheet.get_Range("L4", Missing.Value);
                    range.set_Value(Missing.Value, rdoMan.Checked ? "남" : "여");

                    range = Util.OSheet.get_Range("B5", Missing.Value);
                    range.set_Value(Missing.Value, "자격(" + txtLicenseSubject.Text + "," + cboLicenseLevel.SelectedItem.ToString() + ")\n(" + dtpLicenseDate.Value.ToShortDateString() + ")");

                    range = Util.OSheet.get_Range("G5", Missing.Value);
                    int cmonth = Int32.Parse(cboCMonth.SelectedItem.ToString());
                    range.set_Value(Missing.Value, cboCYear.SelectedItem.ToString() + "." + (cmonth < 10 ? "0" + cmonth.ToString() : cmonth.ToString()) + " ");

                    range = Util.OSheet.get_Range("I5", Missing.Value);
                    int tmonth = Int32.Parse(cboTMonth.SelectedItem.ToString());
                    range.set_Value(Missing.Value, cboTYear.SelectedItem.ToString() + "." + (tmonth < 10 ? "0" + tmonth.ToString() : tmonth.ToString()) + " ");

                    //평정제외경력
                    range = Util.OSheet.get_Range("K5", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getExCareerInfo(txtPCode.Text));

                    range = Util.OSheet.get_Range("B6", Missing.Value);
                    string tmp = "";
                    if (txtUniversityName.Text.Length > 0)
                    {
                        tmp += txtUniversityName.Text + " " + txtCollegeName.Text + " " + txtSpecialName.Text + " 졸업";
                    }
                    if (txtGUniversityName.Text.Length > 0)
                    {
                        tmp += "\n" + txtGUniversityName.Text + " " + txtGCollegeName.Text + " " + txtGSpecialName.Text + " 졸업";
                    }
                    if (txtETCCollegeName.Text.Length > 0)
                    {
                        tmp += "\n" + "시험검정" + txtETCSpecialName.Text + ", " + txtETCCollegeName.Text + " 졸업";
                    }
                    range.set_Value(Missing.Value, tmp);

                    range = Util.OSheet.get_Range("L6", Missing.Value);
                    range.set_Value(Missing.Value, txtFirstSubjectName.Text);

                    ArrayList peList = DBUtil.getPersonalEvalue2009(txtPCode.Text);

                    if (peList.Count != 0)
                    {
                        range = Util.OSheet.get_Range("B9", Missing.Value);
                        range.set_Value(Missing.Value, peList[2]);

                        range = Util.OSheet.get_Range("C9", Missing.Value);
                        range.set_Value(Missing.Value, peList[1]);

                        range = Util.OSheet.get_Range("D9", Missing.Value);
                        range.set_Value(Missing.Value, peList[0]);
                    }

                    range = Util.OSheet.get_Range("B10", Missing.Value);
                    range.set_Value(Missing.Value, txtTotalEvaluePoint.Text);

                    range = Util.OSheet.get_Range("E9", Missing.Value);
                    range.set_Value(Missing.Value, txtCareerpoint.Text);

                    range = Util.OSheet.get_Range("G9", Missing.Value);
                    range.set_Value(Missing.Value, txtEduPoint.Text);

                    range = Util.OSheet.get_Range("H9", Missing.Value);
                    range.set_Value(Missing.Value, txtResearchPoint.Text);

                    range = Util.OSheet.get_Range("I9", Missing.Value);
                    range.set_Value(Missing.Value, txtScholarPoint.Text);

                    range = Util.OSheet.get_Range("G10", Missing.Value);
                    range.set_Value(Missing.Value, txtTotalTrainningPoint.Text);

                    range = Util.OSheet.get_Range("J9", Missing.Value);
                    range.set_Value(Missing.Value, txtAdditionPoint.Text);

                    range = Util.OSheet.get_Range("K9", Missing.Value);
                    range.set_Value(Missing.Value, txtTotalPoint.Text);

                    range = Util.OSheet.get_Range("B11", Missing.Value);
                    range.set_Value(Missing.Value, txtETC.Text);

                    range = Util.OSheet.get_Range("C13", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Evaluer1 + "\n" + Config.Mvi.Evaluer2);

                    range = Util.OSheet.get_Range("I13", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Confirmer);

                    range = Util.OSheet.get_Range("C12", Missing.Value);
                    range.set_Value(Missing.Value, "교감");

                    range = Util.OSheet.get_Range("I12", Missing.Value);
                    range.set_Value(Missing.Value, "교장");

                    /**************
                     * 경력평정표
                     * *************/
                    Util.changeSheet(2);

                    ArrayList careerList = DBUtil.getListFromCareerTable(txtPCode.Text);

                    range = Util.OSheet.get_Range("B3", Missing.Value);
                    range.set_Value(Missing.Value, txtOrganName.Text);

                    range = Util.OSheet.get_Range("E3", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("G3", Missing.Value);
                    range.set_Value(Missing.Value, txtName.Text);

                    //경력평정정보
                    object[,] careerInfo = new object[6, 7];

                    //시작
                    string[] startDate = new string[6];

                    //끝
                    string[] endDate = new string[6];

                    //근무월수
                    int[] workMonth = new int[6];

                    //근무일수
                    int[] workDay = new int[6];

                    //월평정점(기준)
                    double[] pointPerMonth = new double[6];

                    //일평정점(기준)
                    double[] pointPerDay = new double[6];

                    //월평정점
                    double[] monthlyPoint = new double[6];

                    //일평정점
                    double[] dailyPoint = new double[6];

                    //평정점
                    double[] careerPoint = new double[6];

                    for (int i = 0; i < careerList.Count; i++)
                    {
                        ArrayList data = (ArrayList)careerList[i];

                        if (data[2].ToString().Equals("기본경력"))
                        {
                            if (data[3].ToString().Equals("가경력"))
                            {
                                //근무기관명을 축약형으로 변경하여 저장
                                careerInfo[0, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";

                                //처음에 시작 날짜가 없을 경우
                                if (startDate[0] == null) startDate[0] = data[5].ToString();

                                //두 번째 부터는 날짜를 비교하여 현재 시작 날짜보다 더 이전이면 교체
                                if (startDate[0].CompareTo(data[5].ToString()) > 0) startDate[0] = data[5].ToString();

                                //처음에 끝 날짜가 없을 경우
                                if (endDate[0] == null) endDate[0] = data[6].ToString();

                                //두 번째 부터는 날짜를 비교하여 현재 날짜 이후이면 교체
                                if (endDate[0].CompareTo(data[6].ToString()) < 0) endDate[0] = data[6].ToString();

                                //기간을 시작 '~' 끝 형식으로 저장
                                careerInfo[0, 1] = startDate[0].Substring(0, 10) + "~\n" + endDate[0].Substring(0, 10);

                                //평정월수
                                workMonth[0] += (int)data[9];

                                //평정일수
                                workDay[0] += (int)data[10];

                                careerInfo[0, 2] = workMonth[0];

                                careerInfo[0, 3] = workDay[0];

                                pointPerMonth[0] = Util.getCareerMonthPoint("기본경력", "가경력");
                                pointPerDay[0] = Util.getCareerDayPoint("기본경력", "가경력");

                                monthlyPoint[0] = (double)data[11];

                                dailyPoint[0] = (double)data[12];

                                careerPoint[0] += (double)data[13];

                                if (workMonth[0] / 12 >= 18) careerPoint[0] = Util.getCareerMaxPoint("기본경력", "가경력");

                                //월평정점
                                careerInfo[0, 4] = monthlyPoint[0];

                                //일평정점
                                careerInfo[0, 5] = dailyPoint[0];

                                //평정점
                                careerInfo[0, 6] = careerPoint[0];

                            }
                            else if (data[3].ToString().Equals("나경력"))
                            {
                                careerInfo[1, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[1] == null) startDate[1] = data[5].ToString();
                                if (startDate[1].CompareTo(data[5].ToString()) > 0) startDate[1] = data[5].ToString();

                                if (endDate[1] == null) endDate[1] = data[6].ToString();
                                if (endDate[1].CompareTo(data[6].ToString()) < 0) endDate[1] = data[6].ToString();

                                careerInfo[1, 1] = startDate[1].Substring(0, 10) + "~\n" + endDate[1].Substring(0, 10);

                                //평정월수
                                workMonth[1] += (int)data[9];

                                //평정일수
                                workDay[1] += (int)data[10];

                                careerInfo[1, 2] = workMonth[1];

                                careerInfo[1, 3] = workDay[1];

                                pointPerMonth[1] = Util.getCareerMonthPoint("기본경력", "나경력");
                                pointPerDay[1] = Util.getCareerDayPoint("기본경력", "나경력");

                                monthlyPoint[1] = (double)data[11];

                                dailyPoint[1] = (double)data[12];

                                careerPoint[1] += (double)data[13];

                                if (workMonth[1] / 12 >= 18) careerPoint[1] = Util.getCareerMaxPoint("기본경력", "나경력");

                                //월평정점
                                careerInfo[1, 4] = monthlyPoint[1];

                                //일평정점
                                careerInfo[1, 5] = dailyPoint[1];

                                //평정점
                                careerInfo[1, 6] = careerPoint[1];

                            }
                            else if (data[3].ToString().Equals("다경력"))
                            {
                                careerInfo[2, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[2] == null) startDate[2] = data[5].ToString();
                                if (startDate[2].CompareTo(data[5].ToString()) > 0) startDate[2] = data[5].ToString();

                                if (endDate[2] == null) endDate[2] = data[6].ToString();
                                if (endDate[2].CompareTo(data[6].ToString()) < 0) endDate[2] = data[6].ToString();

                                careerInfo[2, 1] = startDate[2].Substring(0, 10) + "~\n" + endDate[2].Substring(0, 10);

                                //평정월수
                                workMonth[2] += (int)data[9];

                                //평정일수
                                workDay[2] += (int)data[10];

                                careerInfo[2, 2] = workMonth[2];

                                careerInfo[2, 3] = workDay[2];

                                monthlyPoint[2] = (double)data[11];

                                dailyPoint[2] = (double)data[12];

                                pointPerMonth[2] = Util.getCareerMonthPoint("기본경력", "다경력");
                                pointPerDay[2] = Util.getCareerDayPoint("기본경력", "다경력");

                                careerPoint[2] += (double)data[13];

                                if (workMonth[2] / 12 >= 18) careerPoint[2] = Util.getCareerMaxPoint("기본경력", "다경력");

                                //월평정점
                                careerInfo[2, 4] = monthlyPoint[2];

                                //일평정점
                                careerInfo[2, 5] = dailyPoint[2];

                                //평정점
                                careerInfo[2, 6] = careerPoint[2];
                            }
                        }
                        else if (data[2].ToString().Equals("초과경력"))
                        {
                            if (data[3].ToString().Equals("가경력"))
                            {
                                careerInfo[3, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[3] == null) startDate[3] = data[5].ToString();
                                if (startDate[3].CompareTo(data[5].ToString()) > 0) startDate[3] = data[5].ToString();

                                if (endDate[3] == null) endDate[3] = data[6].ToString();
                                if (endDate[3].CompareTo(data[6].ToString()) < 0) endDate[3] = data[6].ToString();

                                careerInfo[3, 1] = startDate[3].Substring(0, 10) + "~\n" + endDate[3].Substring(0, 10);

                                //평정월수
                                workMonth[3] += (int)data[9];

                                //평정일수
                                workDay[3] += (int)data[10];

                                careerInfo[3, 2] = workMonth[3];

                                careerInfo[3, 3] = workDay[3];

                                pointPerMonth[3] = Util.getCareerMonthPoint("초과경력", "가경력");
                                pointPerDay[3] = Util.getCareerDayPoint("초과경력", "가경력");

                                monthlyPoint[3] = (double)data[11];

                                dailyPoint[3] = (double)data[12];

                                careerPoint[3] += (double)data[13];

                                if (workMonth[3] / 12 >= 5) careerPoint[3] = Util.getCareerMaxPoint("초과경력", "가경력");

                                //월평정점
                                careerInfo[3, 4] = monthlyPoint[3];

                                //일평정점
                                careerInfo[3, 5] = dailyPoint[3];

                                //평정점
                                careerInfo[3, 6] = careerPoint[3];

                            }
                            else if (data[3].ToString().Equals("나경력"))
                            {
                                careerInfo[4, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[4] == null) startDate[4] = data[5].ToString();
                                if (startDate[4].CompareTo(data[5].ToString()) > 0) startDate[4] = data[5].ToString();

                                if (endDate[4] == null) endDate[4] = data[6].ToString();
                                if (endDate[4].CompareTo(data[6].ToString()) < 0) endDate[4] = data[6].ToString();

                                careerInfo[4, 1] = startDate[4].Substring(0, 10) + "~\n" + endDate[4].Substring(0, 10);

                                //평정월수
                                workMonth[4] += (int)data[9];

                                //평정일수
                                workDay[4] += (int)data[10];

                                careerInfo[4, 2] = workMonth[4];

                                careerInfo[4, 3] = workDay[4];

                                pointPerMonth[4] = Util.getCareerMonthPoint("초과경력", "나경력");
                                pointPerDay[4] = Util.getCareerDayPoint("초과경력", "나경력");

                                monthlyPoint[4] = (double)data[11];

                                dailyPoint[4] = (double)data[12];

                                careerPoint[4] += (double)data[13];

                                if (workMonth[4] / 12 >= 5) careerPoint[4] = Util.getCareerMaxPoint("초과경력", "나경력");

                                //월평정점
                                careerInfo[4, 4] = monthlyPoint[4];

                                //일평정점
                                careerInfo[4, 5] = dailyPoint[4];

                                //평정점
                                careerInfo[4, 6] = careerPoint[4];

                            }
                            else if (data[3].ToString().Equals("다경력"))
                            {
                                careerInfo[5, 0] += Util.getShortSchoolName(data[4].ToString()) + " ";//근무기관

                                if (startDate[5] == null) startDate[5] = data[5].ToString();
                                if (startDate[5].CompareTo(data[5].ToString()) > 0) startDate[5] = data[5].ToString();

                                if (endDate[5] == null) endDate[5] = data[6].ToString();
                                if (endDate[5].CompareTo(data[6].ToString()) < 0) endDate[5] = data[6].ToString();

                                careerInfo[5, 1] = startDate[5].Substring(0, 10) + "~\n" + endDate[5].Substring(0, 10);

                                //평정월수
                                workMonth[5] += (int)data[9];

                                //평정일수
                                workDay[5] += (int)data[10];

                                careerInfo[5, 2] = workMonth[5];

                                careerInfo[5, 3] = workDay[5];

                                pointPerMonth[5] = Util.getCareerMonthPoint("초과경력", "다경력");
                                pointPerDay[5] = Util.getCareerDayPoint("초과경력", "다경력");

                                monthlyPoint[5] = (double)data[11];

                                dailyPoint[5] = (double)data[12];

                                careerPoint[5] += (double)data[13];

                                if (workMonth[5] / 12 >= 5) careerPoint[5] = Util.getCareerMaxPoint("초과경력", "다경력");

                                //월평정점
                                careerInfo[5, 4] = monthlyPoint[5];

                                //일평정점
                                careerInfo[5, 5] = dailyPoint[5];

                                //평정점
                                careerInfo[5, 6] = careerPoint[5];
                            }

                        }

                    }

                    //엑셀에 경력 평정 정보를 입력하는 부분
                    string[] arrCol = new string[] { "C", "D", "E", "F", "G" };
                    string[] arrRow = new string[] { "6", "7", "8", "10", "11", "12" };

                    for (int i = 0; i <= careerInfo.GetUpperBound(0); i++)
                    {
                        if (careerInfo[i, 0] == null) continue;

                        //근무처직명
                        range = Util.OSheet.get_Range(arrCol[0] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, careerInfo[i, 0]);

                        //재직기간
                        range = Util.OSheet.get_Range(arrCol[1] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, careerInfo[i, 1]);

                        //재직월일수
                        range = Util.OSheet.get_Range(arrCol[2] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, "월: " + careerInfo[i, 2] + "\n일: " + careerInfo[i, 3]);

                        //월평정점, 일평정점(규정상의 정해진 점수)
                        range = Util.OSheet.get_Range(arrCol[3] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, "월: " + pointPerMonth[i].ToString("#0.0000") + "\n일: " + pointPerDay[i].ToString("#0.00000"));

                        //평정점 합계                        
                        range = Util.OSheet.get_Range(arrCol[4] + arrRow[i], Missing.Value);
                        range.set_Value(Missing.Value, careerInfo[i, 6]);

                    }

                    //기본경력 평정점 합계
                    range = Util.OSheet.get_Range("G9", Missing.Value);
                    range.set_Value(Missing.Value, (careerPoint[0] + careerPoint[1] + careerPoint[2]).ToString("#0.00000"));

                    //초과경력 평정점 합계
                    range = Util.OSheet.get_Range("G13", Missing.Value);
                    range.set_Value(Missing.Value, (careerPoint[3] + careerPoint[4] + careerPoint[5]).ToString("#0.00000"));

                    //기본경력, 초과경력 평정점 합계
                    range = Util.OSheet.get_Range("G14", Missing.Value);
                    range.set_Value(Missing.Value, (careerPoint[0] + careerPoint[1] + careerPoint[2] + careerPoint[3] + careerPoint[4] + careerPoint[5]).ToString("#0.00000"));

                    //기본경력 월,일수 합계
                    range = Util.OSheet.get_Range("E9", Missing.Value);
                    int tmpMonth = workMonth[0] + workMonth[1] + workMonth[2];
                    int tmpDay = workDay[0] + workDay[1] + workDay[2];
                    if (tmpDay >= 30)
                    {
                        tmpMonth++;
                        tmpDay -= 30;
                    }
                    range.set_Value(Missing.Value, "월: " + tmpMonth + "\n일: " + tmpDay);

                    //초과경력 월,일수 합계
                    range = Util.OSheet.get_Range("E13", Missing.Value);
                    tmpMonth = workMonth[3] + workMonth[4] + workMonth[5];
                    tmpDay = workDay[3] + workDay[4] + workDay[5];
                    if (tmpDay >= 30)
                    {
                        tmpMonth++;
                        tmpDay -= 30;
                    }
                    range.set_Value(Missing.Value, "월: " + tmpMonth + "\n일: " + tmpDay);

                    //전체 월,일수 합계
                    range = Util.OSheet.get_Range("E14", Missing.Value);
                    tmpMonth = workMonth[0] + workMonth[1] + workMonth[2] + workMonth[3] + workMonth[4] + workMonth[5];
                    tmpDay = workDay[0] + workDay[1] + workDay[2] + workDay[3] + workDay[4] + workDay[5];
                    if (tmpDay >= 30)
                    {
                        tmpMonth++;
                        tmpDay -= 30;
                    }
                    range.set_Value(Missing.Value, "월: " + tmpMonth + "\n일: " + tmpDay);

                    range = Util.OSheet.get_Range("B17", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    range = Util.OSheet.get_Range("B18", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    range = Util.OSheet.get_Range("F17", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Evaluer1 + "\n" + Config.Mvi.Evaluer2);

                    range = Util.OSheet.get_Range("F18", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Confirmer);

                    range = Util.OSheet.get_Range("E17", Missing.Value);
                    range.set_Value(Missing.Value, "교감");

                    range = Util.OSheet.get_Range("E18", Missing.Value);
                    range.set_Value(Missing.Value, "교장");

                    /**************
                     * 연수성적평정표
                     * ************/

                    Util.changeSheet(3);

                    range = Util.OSheet.get_Range("B3", Missing.Value);
                    range.set_Value(Missing.Value, txtOrganName.Text);

                    range = Util.OSheet.get_Range("G3", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("K3", Missing.Value);
                    range.set_Value(Missing.Value, txtName.Text);

                    //교육성적
                    ArrayList eduList = DBUtil.getListFromEduTable(txtPCode.Text);

                    string[] eduCol = new string[] { "A", "B", "C", "D", "E", "G", "I", "K" };
                    string[] eduRow = new string[] { "7", "8", "9", "10" };

                    for (int i = 0; i < eduList.Count; i++)
                    {
                        ArrayList data = (ArrayList)eduList[i];

                        range = Util.OSheet.get_Range(eduCol[0] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[2].ToString());

                        range = Util.OSheet.get_Range(eduCol[1] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[3].ToString());

                        range = Util.OSheet.get_Range(eduCol[2] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[4].ToString());

                        range = Util.OSheet.get_Range(eduCol[3] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[5].ToString());

                        range = Util.OSheet.get_Range(eduCol[4] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10) + "~" + data[7].ToString().Substring(0, 10));

                        range = Util.OSheet.get_Range(eduCol[5] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[8].ToString());

                        range = Util.OSheet.get_Range(eduCol[6] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[9].ToString());

                        range = Util.OSheet.get_Range(eduCol[7] + eduRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[10].ToString());
                    }

                    //연구대회
                    ArrayList reslist = DBUtil.getListFromResearchTable(txtPCode.Text);

                    string[] resCol = new string[] { "A", "C", "E", "L" };
                    string[] scale1 = new string[] { "F", "G", "H" };
                    string[] scale2 = new string[] { "I", "J", "K" };
                    string[] resRow = new string[] { "15", "16", "17", "18", "19", "20", "21", "22", "23" };

                    for (int i = 0; i < reslist.Count; i++)
                    {
                        ArrayList data = (ArrayList)reslist[i];
                        range = Util.OSheet.get_Range(resCol[0] + resRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[2].ToString());

                        range = Util.OSheet.get_Range(resCol[1] + resRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[3].ToString());

                        range = Util.OSheet.get_Range(resCol[2] + resRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[4].ToString().Substring(0, 10));

                        string strRange = "";
                        if (data[5].ToString().Equals("전국"))
                        {
                            switch (data[6].ToString())
                            {
                                case "1등급":
                                    strRange = scale1[0].ToString() + resRow[i].ToString();
                                    break;
                                case "2등급":
                                    strRange = scale1[1].ToString() + resRow[i].ToString();
                                    break;
                                case "3등급":
                                    strRange = scale1[2].ToString() + resRow[i].ToString();
                                    break;
                            }
                        }
                        else if (data[5].ToString().Equals("시도"))
                        {
                            switch (data[6].ToString())
                            {
                                case "1등급":
                                    strRange = scale2[0].ToString() + resRow[i].ToString();
                                    break;
                                case "2등급":
                                    strRange = scale2[1].ToString() + resRow[i].ToString();
                                    break;
                                case "3등급":
                                    strRange = scale2[2].ToString() + resRow[i].ToString();
                                    break;
                            }
                        }
                        range = Util.OSheet.get_Range(strRange, Missing.Value);
                        range.set_Value(Missing.Value, "○");

                        range = Util.OSheet.get_Range(resCol[3] + resRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data[8].ToString());
                    }

                    //학위취득실적
                    ArrayList scholarlist = DBUtil.getListFromScholarTable(txtPCode.Text);

                    for (int i = 0; i < scholarlist.Count; i++)
                    {
                        ArrayList data = (ArrayList)scholarlist[i];
                        if (data[2].ToString().Equals("석사"))
                        {
                            if (data[3].ToString().Equals("직무관련"))
                            {
                                range = Util.OSheet.get_Range("C27", Missing.Value);
                                range.set_Value(Missing.Value, data[4].ToString());

                                range = Util.OSheet.get_Range("E27", Missing.Value);
                                range.set_Value(Missing.Value, data[5].ToString());

                                range = Util.OSheet.get_Range("H27", Missing.Value);
                                range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10));

                                range = Util.OSheet.get_Range("K27", Missing.Value);
                                range.set_Value(Missing.Value, data[7].ToString());
                            }
                            else
                            {
                                range = Util.OSheet.get_Range("C28", Missing.Value);
                                range.set_Value(Missing.Value, data[4].ToString());

                                range = Util.OSheet.get_Range("E28", Missing.Value);
                                range.set_Value(Missing.Value, data[5].ToString());

                                range = Util.OSheet.get_Range("H28", Missing.Value);
                                range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10));

                                range = Util.OSheet.get_Range("K28", Missing.Value);
                                range.set_Value(Missing.Value, data[7].ToString());
                            }
                        }
                        else
                        {
                            if (data[3].ToString().Equals("직무관련"))
                            {
                                range = Util.OSheet.get_Range("C29", Missing.Value);
                                range.set_Value(Missing.Value, data[4].ToString());

                                range = Util.OSheet.get_Range("E29", Missing.Value);
                                range.set_Value(Missing.Value, data[5].ToString());

                                range = Util.OSheet.get_Range("H29", Missing.Value);
                                range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10));

                                range = Util.OSheet.get_Range("K29", Missing.Value);
                                range.set_Value(Missing.Value, data[7].ToString());
                            }
                            else
                            {
                                range = Util.OSheet.get_Range("C30", Missing.Value);
                                range.set_Value(Missing.Value, data[4].ToString());

                                range = Util.OSheet.get_Range("E30", Missing.Value);
                                range.set_Value(Missing.Value, data[5].ToString());

                                range = Util.OSheet.get_Range("H30", Missing.Value);
                                range.set_Value(Missing.Value, data[6].ToString().Substring(0, 10));

                                range = Util.OSheet.get_Range("K30", Missing.Value);
                                range.set_Value(Missing.Value, data[7].ToString());
                            }
                        }
                    }

                    range = Util.OSheet.get_Range("C34", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    range = Util.OSheet.get_Range("C35", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    range = Util.OSheet.get_Range("I34", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Evaluer1 + "\n" + Config.Mvi.Evaluer2);

                    range = Util.OSheet.get_Range("I35", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Confirmer);

                    range = Util.OSheet.get_Range("G34", Missing.Value);
                    range.set_Value(Missing.Value, "교감");

                    range = Util.OSheet.get_Range("G35", Missing.Value);
                    range.set_Value(Missing.Value, "교장");

                    /**************
                     * 가산점평정표
                     * ************/

                    Util.changeSheet(4);

                    range = Util.OSheet.get_Range("B3", Missing.Value);
                    range.set_Value(Missing.Value, txtOrganName.Text);

                    range = Util.OSheet.get_Range("E3", Missing.Value);
                    range.set_Value(Missing.Value, txtJobLevel.Text);

                    range = Util.OSheet.get_Range("G3", Missing.Value);
                    range.set_Value(Missing.Value, txtName.Text);

                    ArrayList addList = DBUtil.getListFromAdditionTable(txtPCode.Text);

                    string[] addCol = new string[] { "A", "B", "C", "D", "E", "F", "G" };
                    string[] addRow = new string[] { "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45" };

                    for (int i = 0; i < addList.Count; i++)
                    {
                        Hashtable data = (Hashtable)addList[i];

                        //구분
                        //Console.WriteLine(addCol[0] + addRow[i]);
                        range = Util.OSheet.get_Range(addCol[0] + addRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data["ADD_ITEM_CONTENT"].ToString());

                        //근무기관
                        range = Util.OSheet.get_Range(addCol[1] + addRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data["ADD_ORGAN"].ToString());

                        //근무기간
                        if (data["ADD_GROUP"].ToString().Equals("B08"))
                        {
                            range = Util.OSheet.get_Range(addCol[2] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["TARGET_START"]);

                        }
                        else if (data["ADD_GROUP"].ToString().Equals("A03"))
                        {
                            range = Util.OSheet.get_Range(addCol[2] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["TARGET_START"].ToString().Substring(0, 10) + "~" + data["TARGET_END"].ToString().Substring(0, 10));

                            range = Util.OSheet.get_Range(addCol[4] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["ADD_MONTH"] + "시간");

                            range = Util.OSheet.get_Range(addCol[3] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, ((int)data["ADD_MONTH"] / 15) + "학점");
                        }
                        else
                        {
                            range = Util.OSheet.get_Range(addCol[2] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["ADD_START"].ToString().Substring(0, 10) + "~" + data["ADD_END"].ToString().Substring(0, 10));

                            range = Util.OSheet.get_Range(addCol[3] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, data["TARGET_START"].ToString().Substring(0, 10) + "~" + data["TARGET_END"].ToString().Substring(0, 10));

                            range = Util.OSheet.get_Range(addCol[4] + addRow[i], Missing.Value);
                            range.set_Value(Missing.Value, "월: " + data["ADD_MONTH"].ToString() + "\n일: " + data["ADD_DAY"].ToString());
                        }

                        //평정월/일수
                        range = Util.OSheet.get_Range(addCol[5] + addRow[i], Missing.Value);
                        range.set_Value(Missing.Value, "월: " + data["MONTHLY_POINT"].ToString() + "\n일: " + data["DAILY_POINT"].ToString());

                        //월/일 평정점
                        range = Util.OSheet.get_Range(addCol[6] + addRow[i], Missing.Value);
                        range.set_Value(Missing.Value, data["TOTAL_POINT"].ToString());
                    }

                    //평정자 소속
                    range = Util.OSheet.get_Range("B49", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    //확인자 소속
                    range = Util.OSheet.get_Range("B50", Missing.Value);
                    range.set_Value(Missing.Value, DBUtil.getOrganName(Config.Mvi.Organ));

                    //평정자 성명
                    range = Util.OSheet.get_Range("D49", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Evaluer1 + "\n" + Config.Mvi.Evaluer2);

                    //확인자 성명
                    range = Util.OSheet.get_Range("D50", Missing.Value);
                    range.set_Value(Missing.Value, Config.Mvi.Confirmer);

                    range = Util.OSheet.get_Range("C49", Missing.Value);
                    range.set_Value(Missing.Value, "교감");

                    range = Util.OSheet.get_Range("C50", Missing.Value);
                    range.set_Value(Missing.Value, "교장");
                    
                    string fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\승진후보자평정카드(" + txtPCode.Text + ").xls";
                    FileInfo f = new FileInfo(fileName);

                    if(f.Exists){
                        f.Delete();
                    }

                    Util.OWorkBook.SaveAs(fileName, Missing.Value, Missing.Value ,Missing.Value, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

                    Util.closeXls();

                    MessageBox.Show("내문서에" + "\n\n" + f.Name + " 파일을 내보냈습니다.", "확인");

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Util.closeXls();
                }

            }
        }

        private void txtTarget_MouseClick(object sender, MouseEventArgs e)
        {

            FormCandidateList frmCandidates = new FormCandidateList(this, this.getJobLevel());
            frmCandidates.ShowDialog();
            
        }

        private void txtPCode_MouseClick(object sender, MouseEventArgs e)
        {
            FormCandidateList frmCandidates = new FormCandidateList(this, this.getJobLevel());
            frmCandidates.ShowDialog();
        }

        private void FormACard_Load(object sender, EventArgs e)
        {
            //폼이 로딩될 때 직위를 기본값으로 교사를 선택함
            setJobLevel(0);
        }

        //폼의 직위 선택 값
        private int getJobLevel()
        {
            return cboJobLevel.SelectedIndex;
        }

        //폼 직위 값 설정
        private void setJobLevel(int jobLevel)
        {
            cboJobLevel.SelectedIndex = jobLevel;
        }

        private void txtPCode_TextChanged(object sender, EventArgs e)
        {
            canPrint = false;
        }

        private void txtScholarPoint_TextChanged(object sender, EventArgs e)
        {
            double resPoint = Double.Parse(txtResearchPoint.Text);
            double schPoint = Double.Parse(txtScholarPoint.Text);

            if (resPoint + schPoint > 3.0)
            {
                MessageBox.Show("연구실적평정점은 3점을 초과할 수 없습니다.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtScholarPoint.Text = (3.0 - resPoint).ToString("#0.000");
            }

            calcTrainning();

            calcTotalPoint();
        }

        private void txtResearchPoint_TextChanged(object sender, EventArgs e)
        {
            double resPoint = Double.Parse(txtResearchPoint.Text);
            double schPoint = Double.Parse(txtScholarPoint.Text);

            if (resPoint + schPoint > 3.0)
            {
                MessageBox.Show("연구실적평정점은 3점을 초과할 수 없습니다.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtResearchPoint.Text = (3.0 - schPoint).ToString("#0.000");
            }

            calcTrainning();

            calcTotalPoint();
        }

        private void txtEduPoint_TextChanged(object sender, EventArgs e)
        {
            calcTrainning();

            calcTotalPoint();
        }

        private void txtCareerpoint_TextChanged(object sender, EventArgs e)
        {
            calcTotalPoint();
        }

        private void txtAdditionPoint_TextChanged(object sender, EventArgs e)
        {
            calcTotalPoint();
        }
    }
}
